package action;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import logic.AddressLogic;
import logic.UpdateLogic;
import model.Address;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import action.form.AddressForm;


import dao.AddressDAO;




public class UpdateAction extends Action {

	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception { 
		
	        
	        AddressForm eForm =(AddressForm)form;
	        Address add=new Address();
	        add.setId(eForm.getId());
	        add.setName(eForm.getName());
	        add.setZip(eForm.getZip());
	        add.setAddress1(eForm.getAddress1());
	        add.setAddress2(eForm.getAddress2());
	        add.setTel(eForm.getTel());
	        add.setFax(eForm.getFax());
	        add.setEmail(eForm.getEmail());
	        request.getSession().setAttribute("address",add);
        
	        UpdateLogic uLogic=new UpdateLogic();
	        uLogic.updateAddress(add);
      
	    	AddressLogic logic2 = new AddressLogic();
			logic2.getAllAddresses(request);


	        return mapping.findForward("update");
	    }
	}